﻿using System;
using Skybrud.Social.Twitter.Endpoints;

namespace Skybrud.Social.Twitter {

    public class TwitterService {

        internal TwitterAccessInformation Info { get; private set; }
        public TwitterRestApi RestApi { get; private set; }
        public TwitterStatusesEndpoint Statuses { get; private set; }
        public TwitterUsersEndpoint Users { get; private set; }

        private TwitterService() {
            // make constructor private
        }

        public static TwitterService GetFromAccessInformation(TwitterAccessInformation info) {

            // This should never be null
            if (info == null) throw new ArgumentNullException("info");

            // Initialize the service
            TwitterService service = new TwitterService {
                Info = info
            };

            // Set the endpoints etc.
            service.RestApi = new TwitterRestApi(service);
            service.Statuses = new TwitterStatusesEndpoint(service);
            service.Users = new TwitterUsersEndpoint(service);

            // Return the service
            return service;

        }

    }

}
